/*
**      $Filename: devices/sana2.h $
**      $Revision: 1.1 $
**      $Date: 1993/06/04 11:16:15 $
**
**      Structure definitions for SANA-II devices.
**
**      (C) Copyright 1991 Commodore-Amiga Inc.
**              All Rights Reserved
*/

MODULE  'exec/ports'
MODULE  'exec/io'
MODULE  'exec/errors'
MODULE  'devices/timer'
MODULE  'utility/tagitem'

#define SANA2_MAX_ADDR_BITS      (128)
#define SANA2_MAX_ADDR_BYTES     ((SANA2_MAX_ADDR_BITS+7)/8)

OBJECT IOSana2Req
        Req:IORequest,
        WireError:ULONG,                        /* wire type specific error     */
        PacketType:ULONG,                       /* packet type                  */
        SrcAddr[SANA2_MAX_ADDR_BYTES]:UBYTE,    /* source addr  */
        DstAddr[SANA2_MAX_ADDR_BYTES]:UBYTE,    /* dest address */
        DataLength:ULONG,                       /* length of packet data        */
        Data:PTR TO VOID,                       /* packet data                  */
        StatData:PTR TO VOID,                   /* statistics data pointer      */
        BufferManagement:PTR TO VOID            /* see SANA-II OpenDevice adoc  */

/*
** defines for the io_Flags field
*/

#define SANA2IOB_RAW     (7)                    /* raw packet IO requested      */
#define SANA2IOF_RAW     (1<<SANA2IOB_RAW)
#define SANA2IOB_BCAST   (6)                    /* broadcast packet (received)  */
#define SANA2IOF_BCAST   (1<<SANA2IOB_BCAST)
#define SANA2IOB_MCAST   (5)                    /* multicast packet (received)  */
#define SANA2IOF_MCAST   (1<<SANA2IOB_MCAST)
#define SANA2IOB_QUICK   (IOB_QUICK)            /* quick IO requested (0)       */
#define SANA2IOF_QUICK   (IOF_QUICK)

/*
** defines for OpenDevice() flags
*/

#define SANA2OPB_MINE    (0)                    /* exclusive access requested   */
#define SANA2OPF_MINE    (1<<SANA2OPB_MINE)
#define SANA2OPB_PROM    (1)                    /* promiscuous mode requested   */
#define SANA2OPF_PROM    (1<<SANA2OPB_PROM)

/*
** defines for OpenDevice() tags
*/

#define S2_Dummy         (TAG_USER + $B0000)
#define S2_CopyToBuff    (S2_Dummy + 1)
#define S2_CopyFromBuff  (S2_Dummy + 2)

OBJECT Sana2DeviceQuery
        SizeAvailable:ULONG,     /* bytes available              */
        SizeSupplied:ULONG,      /* bytes supplied               */
        DevQueryFormat:ULONG,    /* this is type 0               */
        DeviceLevel:ULONG,       /* this document is level 0     */
        AddrFieldSize:UWORD,     /* address size in bits         */
        MTU:ULONG,               /* maximum packet data size     */
        BPS:ULONG,               /* line rate (bits/sec)         */
        HardwareType:ULONG       /* what the wire is             */

/*
** defined Hardware types
**
**  If your hardware type isn't listed below contact CATS to get a new
**  type number added for your hardware.
*/

#define S2WireType_Ethernet              1
#define S2WireType_IEEE802               6
#define S2WireType_Arcnet                7
#define S2WireType_LocalTalk             11
#define S2WireType_DyLAN                 12
#define S2WireType_AmokNet               200
#define S2WireType_PPP                   253
#define S2WireType_SLIP                  254
#define S2WireType_CSLIP                 255

OBJECT Sana2PacketTypeStats
        PacketsSent:ULONG,        /* transmitted count            */
        PacketsReceived:ULONG,    /* received count               */
        BytesSent:ULONG,          /* bytes transmitted count      */
        BytesReceived:ULONG,      /* bytes received count         */
        PacketsDropped:ULONG      /* packets dropped count        */

OBJECT Sana2SpecialStatRecord
        Type:ULONG,             /* statistic identifier         */
        Count:ULONG,            /* the statistic                */
        String:PTR TO UBYTE     /* statistic name               */

OBJECT Sana2SpecialStatHeader
        RecordCountMax:ULONG,         /* room available               */
        RecordCountSupplied:ULONG     /* number supplied              */

OBJECT Sana2DeviceStats
        PacketsReceived:ULONG,         /* received count               */
        PacketsSent:ULONG,             /* transmitted count            */
        BadData:ULONG,                 /* bad packets received         */
        Overruns:ULONG,                /* hardware miss count          */
        Unused:ULONG,                  /* Unused field                 */
        UnknownTypesReceived:ULONG,    /* orphan count                 */
        Reconfigurations:ULONG,        /* network reconfigurations     */
        LastStart:TimeVal              /* time of last online          */

/*
** Device Commands
*/
#define S2_START                 (CMD_NONSTD)
#define S2_DEVICEQUERY           (S2_START+ 0)
#define S2_GETSTATIONADDRESS     (S2_START+ 1)
#define S2_CONFIGINTERFACE       (S2_START+ 2)
#define S2_ADDMULTICASTADDRESS   (S2_START+ 5)
#define S2_DELMULTICASTADDRESS   (S2_START+ 6)
#define S2_MULTICAST             (S2_START+ 7)
#define S2_BROADCAST             (S2_START+ 8)
#define S2_TRACKTYPE             (S2_START+ 9)
#define S2_UNTRACKTYPE           (S2_START+10)
#define S2_GETTYPESTATS          (S2_START+11)
#define S2_GETSPECIALSTATS       (S2_START+12)
#define S2_GETGLOBALSTATS        (S2_START+13)
#define S2_ONEVENT               (S2_START+14)
#define S2_READORPHAN            (S2_START+15)
#define S2_ONLINE                (S2_START+16)
#define S2_OFFLINE               (S2_START+17)
#define S2_END                   (S2_START+18)

/*
** defined errors for io_Error  (see also <exec/errors.h>)
*/
#define S2ERR_NO_ERROR           0              /* peachy-keen                  */
#define S2ERR_NO_RESOURCES       1              /* resource allocation failure  */
#define S2ERR_BAD_ARGUMENT       3              /* garbage somewhere            */
#define S2ERR_BAD_STATE          4              /* inappropriate state          */
#define S2ERR_BAD_ADDRESS        5              /* who?                         */
#define S2ERR_MTU_EXCEEDED       6              /* too much to chew             */
#define S2ERR_NOT_SUPPORTED      8              /* hardware can't support cmd   */
#define S2ERR_SOFTWARE           9              /* software error detected      */
#define S2ERR_OUTOFSERVICE       10             /* driver is OFFLINE            */

/*
** From <exec/errors.h>
**
**      IOERR_OPENFAIL   (-1) * device/unit failed to open *
**      IOERR_ABORTED    (-2) * request terminated early [after AbortIO()] *
**      IOERR_NOCMD      (-3) * command not supported by device *
**      IOERR_BADLENGTH  (-4) * not a valid length (usually IO_LENGTH) *
**      IOERR_BADADDRESS (-5) * invalid address (misaligned or bad range) *
**      IOERR_UNITBUSY   (-6) * device opens ok, but requested unit is busy *
**      IOERR_SELFTEST   (-7) * hardware failed self-test *
*/

/*
** defined errors for ios2_WireError
*/
#define S2WERR_GENERIC_ERROR     0              /* no specific info available   */
#define S2WERR_NOT_CONFIGURED    1              /* unit not configured          */
#define S2WERR_UNIT_ONLINE       2              /* unit is currently online     */
#define S2WERR_UNIT_OFFLINE      3              /* unit is currently offline    */
#define S2WERR_ALREADY_TRACKED   4              /* protocol already tracked     */
#define S2WERR_NOT_TRACKED       5              /* protocol not tracked         */
#define S2WERR_BUFF_ERROR        6              /* buff mgt func returned error */
#define S2WERR_SRC_ADDRESS       7              /* source address problem       */
#define S2WERR_DST_ADDRESS       8              /* destination address problem  */
#define S2WERR_BAD_BROADCAST     9              /* broadcast address problem    */
#define S2WERR_BAD_MULTICAST     10             /* multicast address problem    */
#define S2WERR_MULTICAST_FULL    11             /* multicast address list full  */
#define S2WERR_BAD_EVENT         12             /* unsupported event class      */
#define S2WERR_BAD_STATDATA      13             /* statdata failed sanity check */
#define S2WERR_IS_CONFIGURED     15             /* attempt to config twice      */
#define S2WERR_NULL_POINTER      16             /* null pointer detected        */

/*
** defined events
*/
#define S2EVENT_ERROR            (1<<0)         /* error catch all              */
#define S2EVENT_TX               (1<<1)         /* transmitter error catch all  */
#define S2EVENT_RX               (1<<2)         /* receiver error catch all     */
#define S2EVENT_ONLINE           (1<<3)         /* unit is in service           */
#define S2EVENT_OFFLINE          (1<<4)         /* unit is not in service       */
#define S2EVENT_BUFF             (1<<5)         /* buff mgt function error      */
#define S2EVENT_HARDWARE         (1<<6)         /* hardware error catch all     */
#define S2EVENT_SOFTWARE         (1<<7)         /* software error catch all     */


